package com.talent.core.protocol.mqtt.task;

import com.talent.core.protocol.mqtt.model.entity.TlTopic;
import com.talent.core.protocol.mqtt.store.IMqttStore;

import java.util.Set;

/**
 * @ClassName：RemoveSessionTask
 * @Author: hszhou
 * @Date: 2024/12/30 16:39
 * @Description: 必须描述类做什么事情, 实现什么功能
 */
public class RemoveSessionTask {

    private String clientId;

    private Set<TlTopic> topics;

    private IMqttStore mqttStore;





    public RemoveSessionTask(String clientId,
                             Set<TlTopic> topics,
                             IMqttStore mqttStore
                        ){
        this.clientId =clientId;
        this.topics = topics;
        this.mqttStore = mqttStore;
    }

    public void remove(){

        for (TlTopic topic : topics) {
            mqttStore.removeSubClientByTopic(topic.getName(), clientId);
        }

        mqttStore.removeSessionByClientId(clientId);
    }
}
